package com.ruoyi.admin.controller;

import com.ruoyi.admin.service.MemberService;
import com.ruoyi.app.domain.Member;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;

/*
@description:
@ClassName MemberController
@author chen
@create 2025-03-13 17:34
@Version 1.0
*/
@Slf4j
@RestController
@RequestMapping("member")
@AllArgsConstructor
public class MemberController extends BaseController
{
    final MemberService memberService;

    /*
     * @==============History===============<br/>
     * @Description //   根据会员id获取会员详情
     * @Date 2025-3-13 21:40
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return com.ruoyi.framework.web.domain.AjaxResult
     */
    @GetMapping(value = "/getMemberById",produces = "application/json;charset=utf-8")
    public AjaxResult getMemberById(@RequestParam("id") Long id)
    {
        return memberService.selectByPrimaryKey(id);
    }


    /*
     * @==============History===============<br/>
     * @Description //   获取会员列表
     * @Date 2025-3-13 21:49
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return com.ruoyi.framework.web.page.TableDataInfo
     */
    @GetMapping(value = "/getMemberList",produces = "application/json;charset=utf-8")
    public TableDataInfo getMemberList(@RequestParam Map<String, Object> params)
    {
        startPage();
        List<Member> list = memberService.getMemberList(params);
        return getDataTable(list);
    }


    /*
     * @==============History===============<br/>
     * @Description //   更新会员信息
     * @Date 2025-3-13 21:41
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return com.ruoyi.framework.web.domain.AjaxResult
     */
    @PostMapping(value = "/updateMemberInfo",produces = "application/json;charset=utf-8")
    public AjaxResult deleteMemberById(@RequestBody Member member)
    {
        return memberService.updateByPrimaryKeySelective(member);
    }


    /*
     * @==============History===============<br/>
     * @Description //   创建会员信息
     * @Date 2025-3-13 21:43
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return com.ruoyi.framework.web.domain.AjaxResult
     */
    @PostMapping(value = "/insertMemberInfo",produces = "application/json;charset=utf-8")
    public AjaxResult insert(@RequestBody Member member)
    {
        return memberService.insertSelective(member);
    }



    @DeleteMapping(value = "/deleteMemberInfo",produces = "application/json;charset=utf-8")
    public AjaxResult deleteMemberInfo(@RequestParam("id") Long id)
    {
        return memberService.deleteByPrimaryKey(id);
    }





}
